package com.geotmt.billingcenter.modules.hive.provider;

import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description Hive 成本量 SQL
 * @Author      yanghanwei
 * @Mail        yanghanwei@geotmt.com
 * @Date        2019/4/10 11:19
 * @Version     v1
 **/
public class CostHiveProvider {

    private static final Logger logger = LoggerFactory.getLogger(CostHiveProvider.class);

    /**
     * Hive某一天的成本量统计
     * @param dayFlag
     * @return
     */
    public String listCostForDay(String dayFlag){
        StringBuffer sql = new StringBuffer();
        sql.append("select user_id cuserId, outside_if_type outInterfaceType,isp,count_query countQuery,count_get countGet,count_time_out countTimeout,count_charging countCharging,day_flag dayFlag " +
                "from fin_cost_statis where day_flag=#{dayFlag}");
        logger.info("Hive某一天的成本量统计:",sql);
        return sql.toString();
    }

    /**
     * Hive某段时间的成本量统计
     * @param startDay
     * @param endDay
     * @return
     */
    public String listCostForDate(@Param(value = "startDay") String startDay,
                                  @Param(value = "endDay") String endDay){
        StringBuffer sql = new StringBuffer();
        sql.append("select user_id cuserId,outside_if_type outInterfaceType,isp,count_query countQuery,count_get countGet,count_time_out countTimeout,count_charging countCharging,day_flag dayFlag " +
                "from fin_cost_statis where day_flag>=#{startDay} and day_flag<=#{endDay}");
        logger.info("Hive某段时间的成本量统计:",sql);
        return sql.toString();
    }

}
